package com.thb.pay.mchant.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Lists;
import com.thb.pay.api.merchant.MchPayPassageServiceApi;
import com.thb.pay.api.merchant.vo.req.MchPayPassagePageReq;
import com.thb.pay.api.merchant.vo.req.MchPayPassageReq;
import com.thb.pay.api.merchant.vo.resp.MchPayPassageVo;
import com.thb.pay.core.utils.PageResult;
import com.thb.pay.mchant.entity.MchPayPassage;
import com.thb.pay.mchant.service.MchPayPassageService;
import com.xiaoleilu.hutool.bean.BeanUtil;
import com.xiaoleilu.hutool.collection.CollUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商户-支付-通道表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@Slf4j
@RestController
public class MchPayPassageController implements MchPayPassageServiceApi {

    @Autowired
    private MchPayPassageService mchPayPassageService;

    @Override
    public PageResult<MchPayPassageVo> findPage(@RequestBody MchPayPassagePageReq pageReq) {
        return null;
    }

    @Override
    public List<MchPayPassageVo> findAllList() {
        return null;
    }

    @Override
    public List<MchPayPassageVo> findListByMerchantId(@RequestParam("merchantId") Long merchantId) {
        List<MchPayPassageVo> resultDataList = Lists.newArrayList();
        LambdaQueryWrapper<MchPayPassage> wrapper = new LambdaQueryWrapper();
        wrapper.eq(MchPayPassage::getMchId, merchantId);
        List<MchPayPassage> targetDbResultList = mchPayPassageService.selectList(wrapper);
        if (CollUtil.isNotEmpty(targetDbResultList)) {
            targetDbResultList.forEach(mchPayPassage -> {
                MchPayPassageVo resultData = new MchPayPassageVo();
                BeanUtil.copyProperties(mchPayPassage, resultData);
                resultDataList.add(resultData);
            });
        }
        return resultDataList;
    }

    @Override
    public MchPayPassageVo getByMerchantIdAndProductId(@RequestParam("merchantId") Long merchantId, @RequestParam("productId") Long productId) {
        List<MchPayPassageVo> resultDataList = Lists.newArrayList();
        LambdaQueryWrapper<MchPayPassage> wrapper = new LambdaQueryWrapper();
        wrapper.eq(MchPayPassage::getMchId, merchantId);
        List<MchPayPassage> targetDbResultList = mchPayPassageService.selectList(wrapper);
        if (CollUtil.isNotEmpty(targetDbResultList)) {
            MchPayPassageVo resultData = new MchPayPassageVo();
            BeanUtil.copyProperties(targetDbResultList.get(0), resultData);
            return resultData;
        }
        return null;
    }

    @Override
    public List<MchPayPassageVo> findListByIds(@RequestBody List<Long> ids) {
        return null;
    }

    @Override
    public MchPayPassageVo getById(@RequestParam("id") Long id) {
        return null;
    }

    @Override
    public void add(@RequestBody MchPayPassageReq mchPayPassageReq) {

    }

    @Override
    public void update(MchPayPassageReq mchPayPassageReq) {

    }

    @Override
    public void deleteBatchIds(@RequestBody List<Long> ids) {

    }
}
